/**
 * @program: LeetCode
 * @description: LeetCode :
 * @author: WXY
 * @create: 2022-12-09 20:47
 * @Version 1.0
 **/


public class test {
    public static int search(int[] arr,int targe) {
        int left = 0;
        int right = arr.length - 1;
        int mid = 0;
        while (left <= right) {
            mid = (right + left) / 2;
            if (arr[mid] < targe) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        int l = 0;
        int r = arr.length - 1;
        int m = 0;
        while (l <= r) {
            m = (r + l) / 2;
            if (arr[m] <= targe) {
                l = m + 1;
            } else {
                r = m - 1;
            }
        }
        return r - left + 1;
    }

    public static void main(String[] args) {
        int[] arr = {0, 1, 2, 3, 4,4,4,4, 5, 6, 7, 8, 9, 10};
        int search = search(arr, 4);
        System.out.println(search);

    }
}
